<?php
class Default_NewsController extends Zend_Controller_Action {
	public function init() {
		/* Initialize action controller here */
		$this->_model = new Default_Model_DbTable_News ();
	}
	public function indexAction() {
		// action bodys
		$this->view->headTitle ( "Trang Tin Tức", "PREPEND" );
		$allNews = $this->_model->getAllNews ();
		$this->view->topView = $this->_model->topNews ();
		$this->view->random = $this->_model->randomNews ();
		$this->view->GreateView = $this->_model->greatView ();
		$paginator = Zend_Paginator::factory ( $allNews );
		$paginator->setItemCountPerPage ( 9 );
		$paginator->setPageRange ( 5 );
		$currentPage = $this->_request->getParam ( "page", 1 );
		$paginator->setCurrentPageNumber ( $currentPage );
		$this->view->allNews = $paginator;
	}
	public function thongtincongtyAction() {
		$maxId = $this->_model->getNewsMaxId ( 27 );
		
		$maxNews = $this->_model->getNewsById ( $maxId ['m'] );
		$this->view->maxNews = $maxNews;
		
		$this->view->topViewRe = $this->_model->topRecrui ( 27 );
		
		$intro = $this->_model->getNewsByCategoryId1 ( 27, $maxId ['m'] );
		$this->view->intro = $intro;
	}
	public function congnghesoAction() {
		$maxId = $this->_model->getNewsMaxId ( 28 );
		
		$maxNews = $this->_model->getNewsById ( $maxId ['m'] );
		$this->view->maxNews = $maxNews;
		
		$this->view->topViewRe = $this->_model->topRecrui ( 28 );
		
		$intro = $this->_model->getNewsByCategoryId1 ( 28, $maxId ['m'] );
		$this->view->intro = $intro;
	}
	public function hoithaosukienAction() {
		$maxId = $this->_model->getNewsMaxId ( 29 );
		
		$maxNews = $this->_model->getNewsById ( $maxId ['m'] );
		$this->view->maxNews = $maxNews;
		
		$this->view->topViewRe = $this->_model->topRecrui ( 29 );
		
		$intro = $this->_model->getNewsByCategoryId1 ( 29, $maxId ['m'] );
		$this->view->intro = $intro;
	}
	public function mangxahoiAction() {
		$maxId = $this->_model->getNewsMaxId ( 30 );
		
		$maxNews = $this->_model->getNewsById ( $maxId ['m'] );
		$this->view->maxNews = $maxNews;
		
		$this->view->topViewRe = $this->_model->topRecrui ( 30 );
		
		$intro = $this->_model->getNewsByCategoryId1 ( 30, $maxId ['m'] );
		$this->view->intro = $intro;
	}
	public function shownewsAction() {
		$id = $this->_getParam ( "id" );
		$news = $this->_model->getNewsById ( $id );
		$this->view->News = $news;
		$catID = $news ["CATEGORY_ID"];
		$this->view->category = $this->_model->getNewsByCategoryId ( $catID, $id );
		$this->_model->addView ( $id );
	}
	public function morenewsAction() {
		$id = $this->_getParam ( "id" );
		// $this->view->category = $this->_model->getNewsByCategoryId ( $catID
		// );
	}
}



